package com.atguigu.e_map;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Demo2 {
    public static void main(String[] args) {
        //创建双列集合对象
        Map<String, String> map = new HashMap<>();

        //添加元素
        map.put("段延庆","大理王妃");
        map.put("少林方丈","叶二娘");
        map.put("尹志平","小龙女");

        System.out.println("map = " + map);

        //获取装键值对对象[结婚证对象]的集合
        Set<Map.Entry<String, String>> entries = map.entrySet();

        //遍历set集合
        for (Map.Entry<String, String> entry : entries) {
            //根据键值对对象获取键和值
            String key = entry.getKey();
            String value = entry.getValue();
            System.out.println(key +" --- "+ value);
        }
    }
}
